package Day10;

import java.util.Scanner;

/**
 * @author HYHwtx
 * @version 1.0
 * @date 2022/2/16 10:08
 */
public class Demo15 {
    public static void main(String[] args) {
        String[] names= {"白眉鹰王","金毛狮王","紫衫龙王","青翼蝠王"};
        Scanner in = new Scanner(System.in);
        System.out.println("请输入名字：");
        String finalName = in.next();
        int index = -1;
        for (int i = 0; i < names.length; i++) {
            if (finalName.equals(names[i])){
                System.out.println("恭喜您找到："+finalName);
                System.out.println("下标为："+i);
                //把i保存到index中
                index = i;
                break;
            }
        }
        if (index==-1){//没有找到
            System.out.println("sorry,没有找到"+finalName);
        }
    }

}
